package com.xisoft.devise.entity;

import com.xisoft.common.constant.IPubCons;
import com.xisoft.common.db.DbTypeConvert;
import com.xisoft.common.pubEnv.PubEnvUtil;
import com.xisoft.devise.mapper.IGeneratorMapper;
import lombok.Data;

/**
 * * 表字段信息
 * Created with Description:
 *
 * @fileRelativePath: TableFieldEntity.java
 * @Date: Created on 2022/8/10  11:41  <br>
 * @author: LiBencheng <br>
 * @version: 1.0 <br>
 */
@Data
public class TableColEntity
{
    public TableColEntity( )
    { }

    /** 表名 */
    private String tablename;
    private String tablenamelow;
    /** 表说明 */
    private String tablecomments;
    /** 列名 */
    private String columnname;
    /** 类型 */
    private String columntype;
    /** 列说明 */
    private String columncomments;
    /*类型*/
    private String dataType;
    /** 数据长度 */
    private String datalength;
    /** 数据精度 */
    private String dataprecision;
    /** 数据小数位 */
    private String datascale;
    /** 是否主键 */
    private String pk;
    /** 是否是主键 */
    private Boolean isPK = Boolean.FALSE;
    /** 是否可空 */
    private String nullable;

    /** 列说明 */
    private String comment;
    /** 属性名 */
    private String attrName;
    /** 属性类型 */
    private String attrType;
    private Object refobject;

    private String isRefer;

    public void setVtypeByDType(IGeneratorMapper genMapper)
    {
        // setIsPK(Boolean.valueOf(this.getPk()));
        setColumntype(getDataType());
        setAttrName(getColumnname());
        setComment(String.valueOf(columncomments));
        // Map< String,Object > refMap = null;
        // if (PubEnvUtil.unE
        // quals(PubEnvUtil.TRUE, getPk()))
        // { refMap = genMapper.getRefer(getTablename(), getAttrName()); }
        // if (PubEnvUtil.isNotNullObj(refobject))
        if (PubEnvUtil.equals(IPubCons.TRUE, getIsRefer()))
        {
            System.out.println("字段【" + columnname + "】是参照!");
            attrType = "com.xisoft.base.entity.ReferEntity";
        }
        else { attrType = DbTypeConvert.collateDbType2JType(this.dataType, this.datascale); }

    }
}
